<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\11\29 0029
 * Time: 17:40
 */
namespace core\lib;


class Request
{
    private $isAjax;
    private $isGet;
    private $isPost;
    private $host;

    public function __construct()
    {

    }


    public function isAjax(){
        if($this->isAjax === null){
            $this->isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtoupper($_SERVER['HTTP_X_REQUESTED_WITH'])=='XMLHTTPREQUEST';
        }
        return $this->isAjax;
    }

    public function isGet()
    {
        if($this->isGet === null){
            $this->isGet = isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='GET';
        }
        return $this->isGet;
    }

    public function isPost()
    {
        if($this->isPost === null){
            $this->isPost = isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='POST';
        }
        return $this->isPost;
    }

    public function getHost(){
        if($this->host === null){
            $this->host =$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'];
        }
        return $this->host;
    }

}
